import sys

# FIXME: %mlir_native_utils_lib_dir is set incorrectly on Windows
if sys.platform == 'win32':
    config.unsupported = True

# ArmSVE tests must be enabled via build flag.
if config.mlir_run_arm_sve_tests:
    config.substitutions.append(('%ENABLE_VLA', 'true'))
    config.substitutions.append(('%VLA_ARCH_ATTR_OPTIONS', '--march=aarch64 --mattr="+sve"'))
    lli_cmd = 'lli'
    if config.arm_emulator_lli_executable:
       lli_cmd = config.arm_emulator_lli_executable

    if config.arm_emulator_utils_lib_dir:
        config.substitutions.append(('%mlir_native_utils_lib_dir', config.arm_emulator_utils_lib_dir))
    else:
        config.substitutions.append(('%mlir_native_utils_lib_dir', config.mlir_lib_dir))

    if config.arm_emulator_executable:
        # Run test in emulator (qemu or armie).
        emulation_cmd = config.arm_emulator_executable
        if config.arm_emulator_options:
            emulation_cmd = emulation_cmd + ' ' + config.arm_emulator_options
        emulation_cmd = emulation_cmd + ' ' + lli_cmd
        config.substitutions.append(('%lli', emulation_cmd))
    else:
        config.substitutions.append(('%lli', lli_cmd))
else:
    config.substitutions.append(('%ENABLE_VLA', 'false'))
    config.substitutions.append(('%VLA_ARCH_ATTR_OPTIONS', ''))
    config.substitutions.append(('%lli', 'lli'))
    config.substitutions.append(('%mlir_native_utils_lib_dir', config.mlir_lib_dir))
